﻿using Castle.MicroKernel.Registration;
using Castle.Windsor;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.Logging;


namespace XWord.GuyWire.Configurators
{
    public class ComponentsConfigurator : IConfigurator
    {
        public void Configure(IWindsorContainer container)
        {
            container.Register(Component.For(typeof(IModuleInitializer))
                                   .ImplementedBy(typeof(ModuleInitializer)).LifeStyle.Singleton);
            container.Register(Component.For(typeof(ILoggerFacade))
                                   .ImplementedBy(typeof(EmptyLogger)).LifeStyle.Singleton);
            container.Register(Component.For(typeof(IModuleManager))
                                   .ImplementedBy(typeof(ModuleManager)).LifeStyle.Singleton);
            container.Register(Component.For(typeof(IModuleCatalog))
                                   .ImplementedBy(typeof(ConfigurationModuleCatalog)).LifeStyle.Singleton);
            var moduleCatalog = container.Resolve<IModuleCatalog>();
            moduleCatalog.Initialize();
        }
    }
}